extends "../i_TD_pipa/i_TD_pipa.gd"
func init():
	.init()
	name = "魂音琵琶"
	resetdata()
	info = info + "灵魂魔音：向敌方生命上限最高的的单位发射声波，对该单位造成其生命上限5%魔法伤害且附加1层<魔破>和<破甲>，20%概率附加1层<眩晕>，对其造成伤害时还会对其十字范围内单位（不分敌我）造成50%物攻真伤[cd:7秒]"

#技能计时
func _upS():
	._upS()
	cnt2 += 1
	if cnt2 == 7:
		cnt2 = 0
		lhmy()

func lhmy():
	cell = masCha.cell
	var chas = masCha.getAllChas(1)
	chas.sort_custom(self,"sort2")
	masCha.hurtChara(chas[0],chas[0].att.maxHp * 0.05,Chara.HurtType.MGI,Chara.AtkType.SKILL)
	chas[0].addBuff(ctrl.b_mp.new(1))
	chas[0].addBuff(ctrl.b_pj.new(1))
	if sys.rndPer(20):
		chas[0].addBuff(ctrl.b_xuanyun.new(1))
	var v = [Vector2(0,1),Vector2(0,-1),Vector2(1,0),Vector2(-1,0)]
	for i in v:
		if sys.main.isMatin(i+cell):
			var cha = sys.main.matCha(i+cell)
			if cha:
				masCha.hurtChara(cha,masCha.att.atk*0.5,Chara.HurtType.REAL,Chara.AtkType.SKILL)

func sort2(a,b):
	return a.att.maxHp > b.att.maxHp